import { DataSet } from 'choerodon-ui/pro';
import { gatesOperatorData, checkGatesValue, getGatesValueLabel } from './newCodeFailedConditionsDs';

export const fullGatesMetricData = [
  {
    meaning: '总问题数',
    value: 'violations',
  },
  {
    meaning: 'Block问题数',
    value: 'blocker_violations',
  },
  {
    meaning: 'Critical问题数',
    value: 'critical_violations',
  },
  {
    meaning: 'Major问题数',
    value: 'major_violations',
  },
  {
    meaning: 'Minor问题数',
    value: 'minor_violations',
  },
  {
    meaning: '代码重复率',
    value: 'duplicated_lines_density',
  },
];

export default () => ({
  autoQuery: false,
  autoCreate: false,
  fields: [
    {
      name: 'gatesMetric',
      label: '门禁项（全量代码）',
      required: true,
      options: new DataSet({
        data: fullGatesMetricData,
      }),
    },
    {
      name: 'gatesOperator',
      label: '比较逻辑',
      defaultValue: 'GT',
      options: new DataSet({
        data: gatesOperatorData,
      }),
    },
    {
      name: 'gatesValue',
      required: true,
      type: 'number' as any,
      validator: checkGatesValue,
      dynamicProps: {
        label: getGatesValueLabel,
      },
    },
  ],
});
